package com.sky.mapper;

import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.DeleteMapping;

import java.util.List;

@Mapper
public interface SetmealDishMapper {

    /**
     * 根据DishIds查询
     * @param ids
     * @return id数组
     */
    public List<Long> querySetmealByDishIds (List<Long> dishIds);

    /**
     * 根据套餐id查询套餐内的菜品
     * @param id
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id = #{setmealId}")
    List<SetmealDish> getSetmealDIshsBySetmealId(Long setmealId);

    /**
     * 根据setmealId删除数据
     * @param id
     */
    @Delete("delete from setmeal_dish where setmeal_id = #{setmealId}")
    void deletSetmealDishBySetmealId(Long setmealId);

    void insertSetmealDishes(List<SetmealDish> setmealDishes);

    /**
     * 根据setmeaId批量删除数据
     * @param ids
     */
    void deletSetmealDishBySetmealIds(List<Long> setmealIds);

    /**
     * 查看启售中且包含了该dishID菜品的套餐数量
     * @param dishId 菜品ID
     * @return
     */
    Integer getCountByDishId(Long dishId);
}
